/**
 * <b>项目名：</b>hclv-web<br/>  
 * <b>包名：</b>com.flea.hclv.service.impl<br/>  
 * <b>文件名：</b>HHotelServiceImpl.java<br/>  
 * <b>版本信息：</b>1.0<br/>  
 * <b>日期：</b>2018年9月12日 下午3:50:38<br/>  
 * <b>COPYRIGHT 2010-2012 ALL RIGHTS RESERVED 虫子科技</b>-版权所有<br/>
 */
package com.flea.hclv.service.impl;

import com.alibaba.fastjson.JSON;
import com.flea.hclv.model.dao.HlineSpotRelationMapper;
import com.flea.hclv.model.entity.HlineSpotRelation;
import com.flea.hclv.model.entity.vo.LineSpotRelation;
import com.flea.hclv.service.HLineSpotRelationService;
import com.flea.system.base.util.StringUtil;
import com.flea.system.utils.FleaStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description
 * @createTime 2018年9月12日 下午3:50:38
 * @modifyTime
 * @author myflea@163.com
 * @version 1.0
 */
@Service("lineSpotRelationService")
public class HLineSpotRelationServiceImpl implements HLineSpotRelationService {
	@Autowired
	private HlineSpotRelationMapper lineSpotRelationMapper;

	/*
	 * 根据线路id查询记录(non-Javadoc)
	 * @see com.flea.hclv.service.HLineSpotRelationService#queryByLineId(java.lang.String)
	 */
	@Override
	public List<LineSpotRelation> queryByLineId(String id) {
		List<LineSpotRelation> hLine = lineSpotRelationMapper.selectByLineId(id);
		return hLine;
	}
	
	/*
	 * 根据景点id查询记录(non-Javadoc)
	 * @see com.flea.hclv.service.HLineSpotRelationService#queryByLineId(java.lang.String)
	 */
	@Override
	public List<LineSpotRelation> queryBySpotId(String id) {
		return lineSpotRelationMapper.selectBySpotId(id);
	}
	
	/*
	 * 保存，支持批量(non-Javadoc)
	 * @see com.flea.hclv.service.HLineSpotRelationService#save(com.flea.hclv.model.entity.HlineSpotRelation)
	 */
	@Override
	public boolean save(List<HlineSpotRelation> entities, String userId) throws Exception {
		HlineSpotRelation tmp;
		for (HlineSpotRelation entity : entities) {
			tmp = entity;
			if (StringUtil.isEmpty(tmp.getId())) {
				tmp.setId(FleaStringUtils.getGenerateUUID());
			}
			tmp.setCreateUser(userId);
		}
		return lineSpotRelationMapper.insert(entities) > 0;
	}
	/*
	 * 保存，支持批量(non-Javadoc)
	 * @see com.flea.hclv.service.HLineSpotRelationService#save(com.flea.hclv.model.entity.HlineSpotRelation)
	 */
	@Override
	public boolean save(List<HlineSpotRelation> entities) {
		return lineSpotRelationMapper.insert(entities) > 0;
	}
	/*
	 * 根据id删除记录(non-Javadoc)
	 * @see com.flea.hclv.service.HLineSpotRelationService#delete(java.lang.String, java.lang.String)
	 */
	public boolean delete(String ids, String userId) throws Exception {
		return lineSpotRelationMapper.delete(JSON.parseArray(ids, String.class)) > 0;
	}
	
	/*
	 * 根据线路id删除记录(non-Javadoc)
	 * @see com.flea.hclv.service.HLineSpotRelationService#deleteByLineId(java.lang.String, java.lang.String)
	 */
	public boolean deleteByLineId(String lineId, String userId) throws Exception {
		return lineSpotRelationMapper.deleteByLineId(lineId) > 0;
	}

  /**
   * 根据线路ids 进行批量删除
   * @param ids
   * @param userId
   * @return
   * @throws Exception
   */
	public boolean deleteByLineIds(String ids, String userId) throws Exception {
		return lineSpotRelationMapper.deleteByLineIds(JSON.parseArray(ids, String.class)) > 0;
	}
}
